// components/Add_PostList/Add_PostList.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item:{
      type:String
    },
    textID:{
      type:Number 
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
language:[],
isDel:1
  },
  // 点击发表评论
  observers:({
    'item'(item){

      if(item){
        console.log('form发生了submit事件，携带数据为：',item) 
        var arr = this.data.language
        arr.unshift(item)
        this.setData({
          language:arr
        })
      }
      
      }
     
  }),

  /**
   * 组件的方法列表
   */
  methods: {
//删帖子时更新数据库
delUpdate(){
  const that = this
  console.log(this.data.textID)
  wx.request({
    url: 'http://49.233.35.127/Wx/editor/delete/',
    method:"POST",
    data:{
      id:that.data.textID
    },
    success:(res)=>{
      console.log(res)
    }
  })
},


 //删除帖子
 handleRemoveCom(e){
   console.log("del",e.currentTarget)
   const {index} = e.currentTarget.dataset;
   let {language} = this.data;
   var {isDel} = this.data;
   language.splice(index,1);
   this.setData({
     language
   })
   console.log(this.data.isDel)

   this.triggerEvent("comChange",{isDel});

   this.delUpdate()
  },

  }
})
